import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/views/layout/Layout'
import LayoutshareShow from '@/views/layout/LayoutshareShow'

/* Router Modules */
import componentsRouter from './modules/components'
import chartsRouter from './modules/charts'
import tableRouter from './modules/table'
import nestedRouter from './modules/nested'

/** note: Submenu only appear when children.length>=1
 *  detail see  https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 **/

/**
 * hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
 *                                if not set alwaysShow, only more than one route under the children
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noredirect           if `redirect:noredirect` will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']     will control the page roles (you can set multiple roles)
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
    noCache: true                if true ,the page will no be cached(default is false)
  }
 **/
export const constantRouterMap = [
  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path*',
        component: () => import('@/views/redirect/index')
      }
    ]
  },
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  { //分享页面
    path: '/shareShow',
    component: LayoutshareShow,
    redirect: '/shareShow/projectDetails',
    meta: {
      title: '影视详情'
    },
    hidden: true,
    children: [{
      path: 'projectDetails/:id/:login/:authTime/:authStatus',
      component: () => import('@/views/shareShow/projectDetails'),
      meta: {
        title: '影视详情'
      },
      hidden: true
    }, {
      path: 'infomationDetails/:id',
      component: () => import('@/views/shareShow/infomationDetails'),
      meta: {
        title: '资讯详情'
      },
      hidden: true
    }]
  },
  {
    path: '/auth-redirect',
    component: () => import('@/views/login/authredirect'),
    hidden: true
  },
  {
    path: '/404',
    component: () => import('@/views/errorPage/404'),
    hidden: true
  },
  {
    path: '/401',
    component: () => import('@/views/errorPage/401'),
    hidden: true
  },
  {
    path: '',
    component: LayoutshareShow,
    redirect: '/www',
    meta: {
      title: '首页'
    },
    hidden: true,
    children: [{
      path: 'www',
      component: () => import('@/views/www/index'),
      name: 'www',
      meta: {
        title: '首页'
      },
      hidden: true
    }]
  },
  {
    path: '/filmprograms',
    component: () => import('@/views/www/filmprograms'),
    name: 'filmprograms',
    meta: {
      title: '影视项目'
    },
    hidden: true
  },
  {
    path: '/investment',
    component: () => import('@/views/www/Investment'),
    name: 'Investment',
    meta: {
      title: '投资指南'
    },
    hidden: true
  },
  {
    path: '/aboutUs',
    component: () => import('@/views/www/aboutUs'),
    name: 'aboutUs',
    meta: {
      title: '关于我们'
    },
    hidden: true
  },
  {
    path: '/contactUs',
    component: () => import('@/views/www/contactUs'),
    name: 'contactUs',
    meta: {
      title: '联系我们'
    },
    hidden: true
  },
  {
    path: '/projectFillDetails/:movieId',
    component: () => import('@/views/www/projectFillDetails'),
    name: 'projectFillDetails',
    meta: {
      title: '影视详情'
    },
    hidden: true
  },
  {
    path: '/dashboard',
    component: Layout,
    redirect: '/dashboard/index',
    children: [
      {
        path: 'index',
        component: () => import('@/views/dashboard/index'),
        name: 'Dashboard',
        meta: {
          title: 'dashboard',
          icon: 'dashboard',
          noCache: true,
          roles: ['admin', 'issue', 'dealer']
        }
      }
    ]
  },
  // {
  //   path: '',
  //   component: Layout,
  //   redirect: 'dashboard',
  //   children: [
  //     {
  //       path: 'dashboard',
  //       component: () => import('@/views/dashboard/index'),
  //       name: 'Dashboard',
  //       meta: {
  //         title: 'dashboard',
  //         icon: 'dashboard',
  //         noCache: true,
  //         roles: ['admin', 'issue', 'dealer']
  //       }
  //     }
  //   ]
  // },

]

let router = new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({y: 0}),
  routes: constantRouterMap
});

router.beforeEach((to, from, next) => {
  console.log(from.path, to.path)
  next();
});

export default router

export const asyncRouterMap = [
  {   //业务员  -- 经销商
    path: '/salesmanProject',
    component: Layout,
    redirect: '/salesmanProject/index',
    alwaysShow: true,
    meta: {
      title: 'salesmanProject',
      icon: 'guide',
      roles: ['dealer'],
      noCache: true
    },
    children: [{
      path: 'salesmanProject',
      component: () => import('@/views/salesmanProject/index'),
      name: 'salesmanProject',
      meta: {
        title: 'salesmanProject',
        roles: ['dealer'],
        noCache: true
      }
    }, {
      path: 'directMembership/:id',
      component: () => import('@/views/salesmanProject/directMembership'),
      name: 'directMembership',
      meta: {
        title: 'directMembership',
        roles: ['dealer'],
        noCache: true
      },
      hidden: true
    }]
  },
  {
    path: '/projectOverflew',
    component: Layout,
    redirect: '/projectOverflew/allProject',
    alwaysShow: true,
    meta: {
      title: 'projectOverflew',
      icon: 'dashboard',
      roles: ['admin', 'issue'],
      noCache: true
    },
    children: [
      // {
      //   path: 'index',
      //   component: () => import('@/views/projectOverflew/index'),
      //   name: 'index',
      //   meta: {
      //     title: 'indexOrder',
      //     roles: ['admin']
      //   }
      // },
      {
        path: 'allProject',
        component: () => import('@/views/projectOverflew/allProject'),
        name: 'allProject',
        meta: {
          title: 'allProject',
          roles: ['admin', 'issue'],
          noCache: true
        }
      },
      {
        path: 'auditedProject',
        component: () => import('@/views/projectOverflew/auditedProject'),
        name: 'auditedProject',
        meta: {
          title: 'auditedProject',
          noCache: true,
          roles: ['admin', 'issue']
        }
      },
      {
        path: 'sales',
        component: () => import('@/views/projectOverflew/sales'),
        name: 'sales',
        meta: {
          title: 'sales',
          roles: ['admin', 'issue'],
          noCache: true
        }
      },
      {
        path: 'haltsales',
        component: () => import('@/views/projectOverflew/haltsales'),
        name: 'haltsales',
        meta: {
          title: 'haltsales',
          roles: ['admin', 'issue'],
          noCache: true
        }
      },
      {
        path: 'out',
        component: () => import('@/views/projectOverflew/out'),
        name: 'out',
        meta: {
          title: 'out',
          roles: ['admin', 'issue'],
          noCache: true
        }
      },
      {
        path: 'hasBeenIssued',
        component: () => import('@/views/projectOverflew/hasBeenIssued'),
        name: 'hasBeenIssued',
        meta: {
          title: 'hasBeenIssued',
          roles: ['admin', 'issue'],
          noCache: true
        }
      },
      {
        path: 'issued',
        component: () => import('@/views/projectOverflew/issued'),
        name: 'issued',
        meta: {
          title: 'issued',
          roles: ['admin', 'issue'],
          noCache: true
        }
      },
      {
        path: 'preheating',
        component: () => import('@/views/projectOverflew/preheating'),
        name: 'preheating',
        meta: {
          title: 'preheating',
          roles: ['admin', 'issue'],
          noCache: true
        }
      },
      {
        path: 'details/:movieId',
        component: () => import('@/views/projectOverflew/components/details'),
        name: 'details',
        meta: {
          title: 'detailsAdministration',
          roles: ['admin', 'issue'],
          noCache: true
        },
        hidden: true
      },
      {
        path: 'addProjectdetails',
        component: () => import('@/views/projectOverflew/components/addProject/index'),
        name: 'addProjectIndex',
        meta: {
          title: 'addProject',
          roles: ['admin', 'issue'],
          noCache: true
        },
        hidden: true
      },
      {
        path: 'edit/:movieId',
        component: () => import('@/views/projectOverflew/components/editProject/edit'),
        name: 'edit',
        meta: {
          title: 'editdetailsAdministration',
          roles: ['admin', 'issue'],
          noCache: true
        },
        hidden: true
      },
      {
        path: 'examine/:movieId',
        component: () => import('@/views/projectOverflew/components/examineProject/examine'),
        name: 'examine',
        meta: {
          title: 'examinedetailsAdministration',
          roles: ['admin', 'issue'],
          noCache: true
        },
        hidden: true
      },
      {
        path: 'failure',
        component: () => import('@/views/projectOverflew/failure'),
        name: 'failure',
        meta: {
          title: 'failure',
          roles: ['admin', 'issue'],
          noCache: true
        }
      }
    ]
  },
  {
    path: '/OverflewOrder',
    component: Layout,
    redirect: '/projectOrder/projectOrderAll',
    alwaysShow: true,
    meta: {
      title: 'projectOrder',
      icon: 'clipboard',
      roles: ['admin', 'issue', 'dealer'],
      noCache: true
    },
    children: [
      // {
      //   path: 'index',
      //   component: () => import('@/views/projectOrder/index'),
      //   name: 'index',
      //   meta: {
      //     title: 'OverflewOrder',
      //     roles: ['admin']
      //   }
      // },
      {
        path: 'projectOrderAll',
        component: () => import('@/views/projectOrder/projectOrderAll'),
        name: 'projectOrderAll',
        meta: {
          title: 'projectOrderAll',
          roles: ['admin', 'issue', 'dealer'],
          noCache: true
        }
      },
      {
        path: 'quityBeen',
        component: () => import('@/views/projectOrder/quityBeen'),
        name: 'quityBeen',
        meta: {
          title: 'quityBeen',
          roles: ['admin', 'issue'],
          noCache: true
        }
      },
      {
        path: 'contract',
        component: () => import('@/views/projectOrder/contract'),
        name: 'contract',
        meta: {
          title: 'contract',
          roles: ['admin', 'issue'],
          noCache: true
        }
      },
      {
        path: 'unpaidOrder',
        component: () => import('@/views/projectOrder/unpaidOrder'),
        name: 'unpaidOrder',
        meta: {
          title: 'unpaidOrder',
          roles: ['admin', 'issue', 'dealer'],
          noCache: true
        }
      },
      {
        path: 'pastdueOrders',
        component: () => import('@/views/projectOrder/pastdueOrders'),
        name: 'pastdueOrders',
        meta: {
          title: 'pastdueOrders',
          roles: ['admin'],
          noCache: true
        }
      }
    ]
  },
  {
    path: '/user',
    component: Layout,
    redirect: '/user/allMembers',
    alwaysShow: true,
    meta: {
      title: 'user',
      icon: 'peoples',
      roles: ['admin'],
      noCache: true
    },
    children: [
      // {
      //   path: 'index',
      //   component: () => import('@/views/user/index'),
      //   name: 'index',
      //   meta: {
      //     title: 'membershipProfile',
      //     roles: ['admin']
      //   }
      // },
      {
        path: 'allMembers',
        component: () => import('@/views/user/allMembers'),
        name: 'allMembers',
        meta: {
          title: 'allMembers',
          roles: ['admin'],
          noCache: true
        }
      },
      {
        path: 'personnel',
        component: () => import('@/views/user/personnel'),
        name: 'personnel',
        meta: {
          title: 'personnel',
          roles: ['admin'],
          noCache: true
        }
      },
      {
        path: 'distributor',
        component: () => import('@/views/user/distributor'),
        name: 'distributor',
        meta: {
          title: 'distributor',
          roles: ['admin'],
          noCache: true
        }
      },
      // {
      //   path: 'salesman',
      //   component: () => import('@/views/user/salesman'),
      //   name: 'salesman',
      //   meta: {
      //     title: 'salesman',
      //     roles: ['admin']
      //   }
      // },
      {
        path: 'publisher',
        component: () => import('@/views/user/publisher'),
        name: 'publisher',
        meta: {
          title: 'publisher',
          roles: ['admin'],
          noCache: true
        }
      },
      {
        path: 'userDetails/:id',
        component: () => import('@/views/user/components/userDetails'),
        name: 'userDetails',
        meta: {
          title: 'userDetails',
          roles: ['admin'],
          noCache: true
        },
        hidden: true
      },
      {
        path: 'publisherDetails',
        component: () => import('@/views/user/components/publisherDetails'),
        name: 'publisherDetails',
        meta: {
          title: 'publisherDetails',
          roles: ['admin'],
          noCache: true
        },
        hidden: true
      }

    ]
  },
  {
    path: '/drawal',
    component: Layout,
    redirect: '/drawal/index',
    alwaysShow: true,
    meta: {
      title: 'withdrawal',
      icon: 'tree',
      roles: ['admin'],
      noCache: true
    },
    children: [
      {
        path: 'index',
        component: () => import('@/views/drawal/index'),
        name: 'recharge',
        meta: {
          title: 'recharge',
          roles: ['admin'],
          noCache: true
        }
      },
      {
        path: 'caseWithdrawal',
        component: () => import('@/views/drawal/caseWithdrawal'),
        name: 'caseWithdrawal',
        meta: {
          title: 'caseWithdrawal',
          roles: ['admin'],
          noCache: true
        }
      }]
  },
  {
    path: '/informationText',
    component: Layout,
    redirect: '/informationText/index',
    alwaysShow: true,
    meta: {
      title: 'information',
      icon: 'nested',
      roles: ['admin'],
      noCache: true
    },
    children: [
      {
        path: 'index',
        component: () => import('@/views/informationText/index'),
        name: 'informationList',
        meta: {
          title: 'informationList',
          roles: ['admin'],
          noCache: true
        }
      },
      // {
      //   path: 'hotNews',
      //   component: () => import('@/views/informationText/hotNews'),
      //   name: 'hotNews',
      //   meta: {
      //     title: 'hotNews',
      //     roles: ['admin']
      //   }
      // },
      {
        path: 'bulletin',
        component: () => import('@/views/informationText/bulletin'),
        name: 'bulletin',
        meta: {
          title: 'bulletin',
          roles: ['admin'],
          noCache: true
        }
      },
      {
        path: 'bulletinDetails/:bulletinId',
        component: () => import('@/views/informationText/components/bulletinDetails'),
        name: 'bulletinDetails',
        meta: {
          title: 'bulletinDetails',
          roles: ['admin'],
          noCache: true
        },
        hidden: true
      },
      {
        path: 'formationDetails/:formationId',
        component: () => import('@/views/informationText/components/details'),
        name: 'formationDetails',
        meta: {
          title: 'formationDetails',
          roles: ['admin'],
          noCache: true
        },
        hidden: true
      }]
  },
  {
    path: '/informationFeedback',
    component: Layout,
    redirect: 'informationFeedback',
    children: [{
      path: 'informationFeedback',
      component: () => import('@/views/informationFeedback/index'),
      name: 'informationFeedback',
      meta: {
        title: 'informationFeedback',
        icon: 'nested', 
        roles: ['admin'],
        noCache: true
      }
    }]
  },
  {
    path: '/examineDocument',
    component: Layout,
    redirect: '/examineDocument/index',
    alwaysShow: true,
    meta: {
      title: 'examine',
      icon: 'icon',
      roles: ['admin'],
      noCache: true
    },
    children: [
      {
        path: 'index',
        component: () => import('@/views/examineDocument/index'),
        name: 'authentication',
        meta: {
          title: 'authentication',
          roles: ['admin'],
          noCache: true
        }
      },
      {
        path: 'bankCard',
        component: () => import('@/views/examineDocument/bankCard'),
        name: 'bankCard',
        meta: {
          title: 'bankCard',
          roles: ['admin'],
          noCache: true
        }
      },
      {
        path: 'invoice',
        component: () => import('@/views/examineDocument/invoice'),
        name: 'invoice',
        meta: {
          title: 'invoice',
          roles: ['admin'],
          noCache: true
        }
      }]
  },
  {
    path: '/setting',
    component: Layout,
    redirect: '/setting/index',
    alwaysShow: true,
    meta: {
      title: 'setting',
      icon: 'user',
      roles: ['admin'],
      noCache: true
    },
    children: [
      {
        path: 'index',
        component: () => import('@/views/setting/index'),
        name: 'setup',
        meta: {
          title: 'setup',
          roles: ['admin'],
          noCache: true
        }
      }
    ]
  },
  // {
  //   path: '/permission',
  //   component: Layout,
  //   redirect: '/permission/index',
  //   alwaysShow: true, // will always show the root menu
  //   meta: {
  //     title: 'permission',
  //     icon: 'lock',
  //     roles: ['admin', 'editor'] // you can set roles in root nav
  //   },
  //   children: [
  //     {
  //       path: 'page',
  //       component: () => import('@/views/permission/page'),
  //       name: 'PagePermission',
  //       meta: {
  //         title: 'pagePermission',
  //         roles: ['admin'] // or you can only set roles in sub nav
  //       }
  //     },
  //     {
  //       path: 'directive',
  //       component: () => import('@/views/permission/directive'),
  //       name: 'DirectivePermission',
  //       meta: {
  //         title: 'directivePermission'
  //         // if do not set roles, means: this page does not require permission
  //       }
  //     }
  //   ]
  // },

  // {
  //   path: '/icon',
  //   component: Layout,
  //   children: [
  //     {
  //       path: 'index',
  //       component: () => import('@/views/svg-icons/index'),
  //       name: 'Icons',
  //       meta: { title: 'icons', icon: 'icon', noCache: true }
  //     }
  //   ]
  // },

  // /** When your routing table is too long, you can split it into small modules**/
  // componentsRouter,
  // chartsRouter,
  // nestedRouter,
  // tableRouter,

  // {
  //   path: '/example',
  //   component: Layout,
  //   redirect: '/example/list',
  //   name: 'Example',
  //   meta: {
  //     title: 'example',
  //     icon: 'example'
  //   },
  //   children: [
  //     {
  //       path: 'create',
  //       component: () => import('@/views/example/create'),
  //       name: 'CreateArticle',
  //       meta: { title: 'createArticle', icon: 'edit' }
  //     },
  //     {
  //       path: 'edit/:id(\\d+)',
  //       component: () => import('@/views/example/edit'),
  //       name: 'EditArticle',
  //       meta: { title: 'editArticle', noCache: true },
  //       hidden: true
  //     },
  //     {
  //       path: 'list',
  //       component: () => import('@/views/example/list'),
  //       name: 'ArticleList',
  //       meta: { title: 'articleList', icon: 'list' }
  //     }
  //   ]
  // },

  // {
  //   path: '/tab',
  //   component: Layout,
  //   children: [
  //     {
  //       path: 'index',
  //       component: () => import('@/views/tab/index'),
  //       name: 'Tab',
  //       meta: { title: 'tab', icon: 'tab' }
  //     }
  //   ]
  // },

  // {
  //   path: '/error',
  //   component: Layout,
  //   redirect: 'noredirect',
  //   name: 'ErrorPages',
  //   meta: {
  //     title: 'errorPages',
  //     icon: '404'
  //   },
  //   children: [
  //     {
  //       path: '401',
  //       component: () => import('@/views/errorPage/401'),
  //       name: 'Page401',
  //       meta: { title: 'page401', noCache: true }
  //     },
  //     {
  //       path: '404',
  //       component: () => import('@/views/errorPage/404'),
  //       name: 'Page404',
  //       meta: { title: 'page404', noCache: true }
  //     }
  //   ]
  // },

  // {
  //   path: '/error-log',
  //   component: Layout,
  //   redirect: 'noredirect',
  //   children: [
  //     {
  //       path: 'log',
  //       component: () => import('@/views/errorLog/index'),
  //       name: 'ErrorLog',
  //       meta: { title: 'errorLog', icon: 'bug' }
  //     }
  //   ]
  // },

  // {
  //   path: '/excel',
  //   component: Layout,
  //   redirect: '/excel/export-excel',
  //   name: 'Excel',
  //   meta: {
  //     title: 'excel',
  //     icon: 'excel'
  //   },
  //   children: [
  //     {
  //       path: 'export-excel',
  //       component: () => import('@/views/excel/exportExcel'),
  //       name: 'ExportExcel',
  //       meta: { title: 'exportExcel' }
  //     },
  //     {
  //       path: 'export-selected-excel',
  //       component: () => import('@/views/excel/selectExcel'),
  //       name: 'SelectExcel',
  //       meta: { title: 'selectExcel' }
  //     },
  //     {
  //       path: 'upload-excel',
  //       component: () => import('@/views/excel/uploadExcel'),
  //       name: 'UploadExcel',
  //       meta: { title: 'uploadExcel' }
  //     }
  //   ]
  // },

  // {
  //   path: '/zip',
  //   component: Layout,
  //   redirect: '/zip/download',
  //   alwaysShow: true,
  //   meta: { title: 'zip', icon: 'zip' },
  //   children: [
  //     {
  //       path: 'download',
  //       component: () => import('@/views/zip/index'),
  //       name: 'ExportZip',
  //       meta: { title: 'exportZip' }
  //     }
  //   ]
  // },

  // {
  //   path: '/theme',
  //   component: Layout,
  //   redirect: 'noredirect',
  //   children: [
  //     {
  //       path: 'index',
  //       component: () => import('@/views/theme/index'),
  //       name: 'Theme',
  //       meta: { title: 'theme', icon: 'theme' }
  //     }
  //   ]
  // },

  // {
  //   path: '/clipboard',
  //   component: Layout,
  //   redirect: 'noredirect',
  //   children: [
  //     {
  //       path: 'index',
  //       component: () => import('@/views/clipboard/index'),
  //       name: 'ClipboardDemo',
  //       meta: { title: 'clipboardDemo', icon: 'clipboard' }
  //     }
  //   ]
  // },

  // {
  //   path: '/i18n',
  //   component: Layout,
  //   children: [
  //     {
  //       path: 'index',
  //       component: () => import('@/views/i18n-demo/index'),
  //       name: 'I18n',
  //       meta: { title: 'i18n', icon: 'international' }
  //     }
  //   ]
  // },

  // {
  //   path: 'external-link',
  //   component: Layout,
  //   children: [
  //     {
  //       path: 'https://github.com/PanJiaChen/vue-element-admin',
  //       meta: { title: 'externalLink', icon: 'link' }
  //     }
  //   ]
  // },

  {path: '*', redirect: '/404', hidden: true}
]
